$(function () {
    share();
    loadFoot(2);
    //TODO:获取信息
    $.ajax({
        url: host + '/CMSAPI/GetPartner?openid=' + openid + '&cid=' + cid,
        type: 'GET',
        success: function (data) {
            if (data.state) {
                var main = data.data;
                var RealName = main.RealName || '';
                var Phone = main.Phone || '';
                var Position = main.Position || '';
                var addr = main.addr || '';
                var Company = main.Company || '';
                var industry = main.industry || '';
                $('.name>span').html(RealName)
                $('.phone>span').html(Phone)
                $('.addr>span').html(addr)
                $('.position>span').html(Position)
                $('.industry>span').html(industry)
                $('.company>span').html(Company)
            }
        }
    })
    //TODO:点击li进入修改页面，同时要记住当前点击的是什么list项
    $('.centerList').on('click', 'li', function () {
        var listName = $(this).attr('data-list');
        var title = $(this).attr('data-title');
        var info = $(this).find('.info').html();
        window.location.href = 'modify.html?listName=' + listName + '&info=' + info + '&title=' + title;
    })
    $('.exit-btn').click(function () {
        $.Dialog({
            type: 'confirm',
            textColor: '#2c2c2c',
            content: '退出后将需要重新登录，确定退出吗？',
            callBack: function () {
                $.ajax({
                    url: host + 'mtmlapi/Logout',
                    type: 'POST',
                    data: {
                        openid: openid,
                        cid: cid,
                        ispartner: true
                    },
                    success: function (res) {
                        if (res.state) {
                            window.localStorage.clear()
                            $.Dialog({content: res.message})
                            setTimeout(function () {
                               window.open('login.html')
                            }, 1000)
                        } else {
                            $.Dialog({content: res.message})
                        }
                    }
                })
            }
        })
    })
})
